home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / utility / blrmu13.zip / DIV.ASM < prev    next >
Assembly Source File  |  1991-10-14  |  14KB  |  535 lines

  1. page ,132
  2. title div ( display interrupt vector ) as of 10/14/91 - 01:30 pm
  3. ;*-------------------------------------------------
  4. ;
  5. ;   display interrupt vector
  6. ;   for any requested interrupt
  7. ;
  8. ;   vector table syntax : ( lo-hi format )
  9. ;   offset : segment
  10. ;   (word) : (word)
  11. ;
  12. ;   display syntax :      ( hi-lo format )
  13. ;   segment : offset
  14. ;   (word)    (word)
  15. ;*-------------------------------------------------
  16.  
  17. ;*---------------------------
  18. csroff   macro
  19. ;*---------------------------
  20. ;*   cursor off
  21. ;*---------------------------
  22. ;
  23.          push  ax
  24.          push  cx
  25.          mov   ah,1
  26.          mov   ch,32
  27.          int   10h
  28.          pop   cx
  29.          pop   ax
  30.          endm
  31. ;
  32. ;*---------------------------
  33. csron    macro
  34. ;*---------------------------
  35. ;*   cursor on
  36. ;*---------------------------
  37.          push  ax
  38.          push  cx
  39.          mov   ah,1
  40.          mov   ch,stcsl                ; restore the crsr start line
  41.          mov   cl,stcel                ; restore the crsr end line
  42.          int   10h
  43.          pop   cx
  44.          pop   ax
  45.          endm
  46. ;
  47. ;*---------------------------
  48. csrsv    macro
  49. ;*---------------------------
  50. ;*   cursor save
  51. ;*---------------------------
  52.          push  ax
  53.          push  bx
  54.          push  cx
  55.          mov   ah,3
  56.          mov   bh,0
  57.          int   10h
  58.          mov   stcsl,ch                ; save the crsr start line
  59.          mov   stcel,cl                ; save the crsr end line
  60.          pop   cx
  61.          pop   bx
  62.          pop   ax
  63.          endm
  64. ;
  65. ;*-------------------------------------
  66. ;*   direct console input
  67. ;*-------------------------------------
  68. dci      macro cic
  69.          mov   ah,7
  70.          int   21h
  71.          mov   cic,al
  72.          endm
  73. ;
  74. ;*------------------------------------
  75. lm       macro msg
  76. ;*------------------------------------
  77. ;*  list message
  78. ;*------------------------------------
  79.          lea   ax,msg
  80.          call  lmts
  81.          endm
  82. ;
  83. ;*--------------------------------------
  84. mswl     macro dest,sors,len
  85. ;*--------------------------------------
  86. ;* move short with length
  87. ;---------------------------------------
  88. ;* dest = destination of move
  89. ;* sors = source of move
  90. ;* len  = max length of move
  91. ;--------------------------------------
  92. ;* length may be from 1 to 255
  93. ;* length must be db if variable
  94. ;*--------------------------------------
  95.          push  cx
  96.          push  di
  97.          push  si
  98.          mov   ch,0
  99.          mov   cl,len
  100.          lea   di,dest
  101.          lea   si,sors
  102.          cld
  103.          rep   movsb
  104.          pop   si
  105.          pop   di
  106.          pop   cx
  107.          endm
  108. ;
  109. ;*------------------------------------
  110. pc       macro fld,len,char
  111. ;*------------------------------------
  112. ;* propagate character
  113. ;*------------------------------------
  114. ;* the area named 'fld',
  115. ;* for a length of 'len'
  116. ;* will be filled with 'char'
  117. ;*------------------------------------
  118.          push  ax
  119.          push  cx
  120.          push  di
  121.          lea   di,fld
  122.          mov   cx,len
  123.          mov   al,char
  124.          cld
  125.          rep   stosb
  126.          pop   di
  127.          pop   cx
  128.          pop   ax
  129.          endm
  130. ;
  131. ;*------------------------------------
  132. pm       macro msg
  133. ;*------------------------------------
  134. ;* print message
  135. ;* ( by calling pmtp )
  136. ;*------------------------------------
  137.          lea   ax,msg
  138.          call  pmtp
  139.          endm
  140. ;
  141. ;*--------------------------------------
  142. rk       macro kpa
  143. ;*--------------------------------------
  144. ;* read keyboard
  145. ;*--------------------------------------
  146. ;* kpa = keyboard parameter area
  147. ;* function 10 = read buffered keyboard
  148. ;*--------------------------------------
  149.          lea   dx,kpa
  150.          mov   ah,10
  151.          int   33
  152.          endm
  153. ;
  154. ;*--------------------------
  155. ;*   macro pool end
  156. ;*--------------------------
  157. ;
  158. ;   equates
  159. ;
  160. z        equ   0
  161. mci      equ   3
  162. four     equ   4
  163. lf       equ   10
  164. cr       equ   13
  165.  
  166.          .model small
  167.          .code
  168. ;
  169.          org   256
  170. ;
  171. go:      jmp   divs
  172. ;
  173. ;   data area
  174. ;
  175. stcsl    db    z                       ; save the crsr start line
  176. stcel    db    z                       ; save the crsr end line
  177. ;
  178. voa1     db    z                       ; vector offset address 1
  179. voa2     db    z                       ; vector offset address 2
  180. vsa1     db    z                       ; vector segment address 1
  181. vsa2     db    z                       ; vector segment address 2
  182. ;
  183. ;  request vector msg
  184. ;
  185. rvm      db    cr,lf,lf
  186.          db    '   * key requested interrupt # ( in hex ) : '
  187.          db    z
  188. ;
  189. qm       db    cr,lf,lf
  190.          db    '   * press Enter when ready to quit '
  191.          db    z
  192. ;
  193. ;  vector address msg
  194. ;
  195. vam      db    cr,lf,lf
  196.          db    '   * vector address : '
  197.          db    ' segment = '
  198. vsv      db    'xxxx'
  199.          db    ' , '
  200.          db    ' offset = '
  201. vov      db    'xxxx'
  202.          db    z
  203. ;
  204. cll      db    cr,lf,lf,z              ; cr, lf, lf
  205. ;
  206. rr       db    z                       ; reg result
  207. ;
  208. srp      db    mci dup (' ')           ; save requested pick
  209. ;
  210. rv       db    z                       ; req value
  211. mrv      dw    z                       ; mult req value
  212. mbtf     dw    z                       ; work field
  213. ;
  214. ;*----------------------------
  215. ;*   keyboard parameter list
  216. ;*----------------------------
  217. kpl      label byte
  218. bs       db    mci                     ; buffer size
  219. be       db    z                       ; bytes entered
  220. kb       db    mci dup(' ')            ; keyboard buffer
  221. ;
  222. ;  temp value msg
  223. ;
  224. tvm      db    cr,lf,lf
  225.          db    '   * requested vector = '
  226. rvv      db    'xx'
  227.          db    ' , '
  228.          db    ' mult req vector = '
  229. mrvv     db    '    '
  230.          db    z
  231. ;
  232. ;  code
  233. ;
  234. divs:
  235.          csrsv                         ; cursor save
  236.          csroff                        ; cursor off
  237.          call green                    ; set scrn to green
  238.  
  239. ;
  240. ;   request vector in hex
  241. ;
  242.          lm    rvm                     ; display request vector msg
  243. ;
  244.          csron                         ; cursor on
  245.          rk    kpl                     ; get 2 digit pick
  246.          csroff                        ; cursor off
  247.          pc    srp,2,32                ; clear save requested pick
  248.          mswl  srp,kb,be               ; move requested pick
  249. ;
  250. ;  adjust ascii input to hex
  251. ;
  252.          mov   al,srp+1                ; get lo-order byte
  253.          call  cath                    ; call ascii to hex
  254.          mov   rv,al                   ; save converted byte
  255.          mov   al,srp                  ; get hi-order byte
  256.          call  cath                    ; call ascii to hex
  257.          shl   al,1                    ; shift
  258.          shl   al,1                    ; the
  259.          shl   al,1                    ; byte
  260.          shl   al,1                    ; for or
  261.          or    rv,al                   ; or it with saved byte
  262. ;
  263. ;   multiply interrupt # by 4
  264. ;
  265.          mov   ah,0                    ; clear hi-order
  266.          mov   al,rv                   ; get value
  267.          mov   bl,four                 ; get value of 4
  268.          mul   bl                      ; multiply
  269.          mov   mrv,ax                  ; save result
  270.          jmp   gad                     ; bypass displays
  271. ;
  272. ;   display requested entry
  273. ;
  274.          mov   al,rv
  275.          call  chta
  276.          mov   rvv,dh
  277.          mov   rvv+1,dl
  278. ;
  279.          mov   ax,mrv
  280.          mov   bx,4
  281.          lea   si,mrvv
  282.          call  cbwtas
  283. ;
  284.          lm    tvm
  285.          dci   rr
  286. ;
  287. ;     get and display
  288. ;
  289. ;   ( the interrupt vector address contents )
  290. ;   ( for the requested interrupt vector )
  291. ;
  292. gad:
  293.          push  es                      ; save es
  294. ;
  295.          mov   ax,0                    ; set es
  296.          mov   es,ax                   ; to 0
  297.          mov   bx,mrv                  ; set bx to request
  298. ;
  299.          mov   al,es:[bx]              ; get contents
  300.          mov   voa2,al                 ; of vector
  301.          mov   al,es:[bx+1]            ; offset
  302.          mov   voa1,al                 ; address
  303. ;
  304.          mov   al,es:[bx+2]            ; get contents
  305.          mov   vsa2,al                 ; of vector
  306.          mov   al,es:[bx+3]            ; segment
  307.          mov   vsa1,al                 ; address
  308. ;
  309.          pop   es                      ; restore es
  310. ;
  311. ;    display vector address msg
  312. ;
  313.          mov   al,voa1
  314.          call  chta
  315.          mov   vov,dh
  316.          mov   vov+1,dl
  317.  
  318.          mov   al,voa2
  319.          call  chta
  320.          mov   vov+2,dh
  321.          mov   vov+3,dl
  322. ;
  323.          mov   al,vsa1
  324.          call  chta
  325.          mov   vsv,dh
  326.          mov   vsv+1,dl
  327.  
  328.          mov   al,vsa2
  329.          call  chta
  330.          mov   vsv+2,dh
  331.          mov   vsv+3,dl
  332.  
  333.          lm    vam
  334.          lm    qm
  335.          dci   rr
  336. ;
  337.          lm    cll
  338.          csron
  339. ;
  340.          mov   al,0         ; set cond code to 0
  341.          mov   ah,76        ; and exit
  342.          int   33
  343. ;
  344. ;*------------------------------
  345. ;*   catb.prc
  346. ;*------------------------------
  347. ;*   convert ascii to binary
  348. ;*------------------------------
  349. ;* converts an ascii decimal
  350. ;* input number
  351. ;* pointed to by si,
  352. ;* to a dw binary output field
  353. ;* pointed to by di,
  354. ;* with the input field width
  355. ;* in bx,
  356. ;* and using a dw multiply
  357. ;* temporary field named mbtf
  358. ;*------------------------------
  359. catb     proc  near
  360.          push  ax
  361.          push  cx
  362.          mov   cx,10
  363.          mov   mbtf,1
  364.          sub   si,1
  365. ;
  366. catbl:
  367.          mov   al,[si+bx]
  368.          and   ax,000fh
  369.          mul   mbtf
  370.          add   [di],ax
  371.          mov   ax,mbtf
  372.          mul   cx
  373.          mov   mbtf,ax
  374.          dec   bx
  375.          jnz   catbl
  376.          pop   cx
  377.          pop   ax
  378.          ret
  379. catb     endp
  380. ;
  381. ;*-------------------------------
  382. ;   cath.prc
  383. ;*-------------------------------
  384. ;* convert ascii to hex
  385. ;* byte is in al both ways
  386. ;*-------------------------------
  387. cath     proc  near
  388.          sub   al,48
  389.          jb    athe
  390.          cmp   al,10
  391.          jb    athx
  392.          sub   al,39
  393.          cmp   al,16
  394.          jnb   athe
  395.          cmp   al,10
  396.          jnb   athx
  397. athe:    mov   al,255
  398. athx:    ret
  399. cath     endp
  400. ;
  401. ;*-----------------------------------------------
  402. ;   cbwtas.prc
  403. ;*-----------------------------------------------
  404. ;*   convert binary word to ascii string
  405. ;*-----------------------------------------------
  406. ;*  before call set :
  407. ;*
  408. ;* ax = binary number
  409. ;* bx = length of output field
  410. ;* si = pointer to output field
  411. ;*------------------------------------------------
  412. cbwtas   proc  near
  413.          push  cx
  414.          push  dx
  415.          mov   cx,10
  416.          sub   bx,1
  417.          add   si,bx
  418. ;
  419. cbtavsl:
  420.          cmp   ax,0010
  421.          jb    cbtavsx
  422.          sub   dx,dx
  423.          div   cx
  424.          or    dl,48
  425.          mov   [si],dl
  426.          dec   si
  427.          jmp   cbtavsl
  428. ;
  429. cbtavsx:
  430.          or    al,48
  431.          mov   [si],al
  432.          pop   dx
  433.          pop   cx
  434.          ret
  435. cbwtas   endp
  436. ;
  437. ;*--------------------------------------
  438. ;*   chta.prc
  439. ;*--------------------------------------
  440. ;* convert hex to ascii ( 1 byte )
  441. ;*--------------------------------------
  442. ;* byte to be converted is passed in al
  443. ;* the hi nibble is passed back in dh
  444. ;* the lo nibble is passed back in dl
  445. ;*--------------------------------------
  446. ;
  447. chta     proc  near
  448. ;   convert hi nibble
  449.          mov   dh,al  ; move byte for hi conversion
  450.          shr   dh,1   ; shift
  451.          shr   dh,1   ; out
  452.          shr   dh,1   ; lo
  453.          shr   dh,1   ; nibble
  454.          add   dh,48  ; add ascii zero
  455.          cmp   dh,58  ; > than 9 ?
  456.          jl    chtadl ; if not, carry on
  457.          add   dh,7   ; else, convert to a-f
  458. chtadl:
  459. ;   convert lo nibble
  460.          mov   dl,al  ; move byte for lo conversion
  461.          and   dl,15  ; get rid of hi nibble
  462.          add   dl,48  ; add ascii zero
  463.          cmp   dl,58  ; > than 9 ?
  464.          jl    chtax  ; if not, carry on
  465.          add   dl,7   ; else, convert to a-f
  466. chtax:
  467.          ret
  468. chta     endp
  469. ;
  470. ;*-------------------------
  471. ;*   green prc
  472. ;*-------------------------
  473. ;*   change screen to
  474. ;*   white on green
  475. ;*-------------------------
  476. ;
  477. green    proc  near
  478. ;
  479.          mov   ah,11                   ; set color palette fct
  480.          mov   bh,0                    ; text mode
  481.          mov   bl,15                   ; border = white
  482.          int   16
  483. ;
  484.          mov   ah,2                    ; set cursor position fct
  485.          mov   bh,0                    ; page number 0
  486.          mov   dh,0                    ; row 0
  487.          mov   dl,0                    ; col 0
  488.          int   16
  489. ;
  490.          mov   ah,9                    ; write char and attr fct
  491.          mov   al,32                   ; char = space
  492.          mov   bh,0                    ; page number 0
  493.          mov   bl,47                   ; attr = green back, white crsr
  494.          mov   cx,2000                 ; 25 * 80
  495.          int   16
  496. ;
  497.          ret
  498. green    endp
  499. ;
  500. ;*------------------------------
  501. ;*     lmts.prc
  502. ;*------------------------------
  503. ;*   list msg to screen
  504. ;*------------------------------
  505. ;*   called by macro lm
  506. ;*   using ax as ptr to msg
  507. ;*------------------------------
  508. ;*  msg terminated by final zero
  509. ;*  or max 512 bytes
  510. ;*------------------------------
  511. lmts     proc  near
  512.          push  ax
  513.          push  bx
  514.          push  cx
  515.          push  si
  516.          mov   bx,ax
  517.          mov   cx,512
  518.          mov   si,0
  519. lmtsl:
  520.          mov   al,[bx][si]
  521.          cmp   al,0
  522.          je    lmtsx
  523.          int   41
  524.          inc   si
  525.          loop  lmtsl
  526. lmtsx:
  527.          pop   si
  528.          pop   cx
  529.          pop   bx
  530.          pop   ax
  531.          ret
  532. lmts     endp
  533. ;
  534.          end   go
  535.